﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace WJP.WPF
{
    public class App
    {
        public static readonly App.AppMessageBox MessageBox = new App.AppMessageBox();

        public class AppMessageBox
        {
            public MessageBoxResult Show(string messageText)
            {
                return Show(messageText, "提示", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            }

            public MessageBoxResult Show(string messageText, MessageBoxButton button)
            {
                return Show(messageText, "提示", button, MessageBoxImage.Asterisk);
            }

            public MessageBoxResult Show(string messageText, MessageBoxImage icon)
            {
                return Show(messageText, "提示", MessageBoxButton.OK, icon);
            }

            public MessageBoxResult Show(string messageText, MessageBoxButton button, MessageBoxImage icon)
            {
                return Show(messageText, "提示", button, icon);
            }

            public MessageBoxResult Show(string messageText, string caption)
            {
                return Show(messageText, caption, MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }

            public MessageBoxResult Show(string messageText, string caption, MessageBoxButton button)
            {
                return Show(messageText, caption, button, MessageBoxImage.Exclamation);
            }

            public MessageBoxResult Show(string msg, string caption, MessageBoxButton button, MessageBoxImage icon)
            {
                OnOpening();
                MessageBoxResult messageBoxResult = WJP.WPF.Controls.Toolkit.MessageBox.Show(msg, caption, button, icon);
                OnClosed();
                return messageBoxResult;
            }

            public event EventHandler Opening;
            protected void OnOpening()
            {
                Opening?.Invoke(this, EventArgs.Empty);
            }

            public event EventHandler Closed;
            protected void OnClosed()
            {
                Closed?.Invoke(this, EventArgs.Empty);
            }
        }
    }
}
